home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 3 / csmp-digest-v3-088 < prev    next >
Encoding:
Internet Message Format  |  1995-06-07  |  51.4 KB  |  [TEXT/R*ch]

  1. From: pottier@clipper.ens.fr (Francois Pottier)
  2. Subject: csmp-digest-v3-088
  3. Date: Mon, 13 Mar 1995 13:22:32 +0100 (MET)
  4.  
  5. C.S.M.P. Digest             Mon, 13 Mar 95       Volume 3 : Issue 88
  6.  
  7. Today's Topics:
  8.  
  9.         Asynchronous Programming?
  10.         Distinguishing QT-compressed PICTs
  11.         Getting TEHandle from dialog item number
  12.         How to get a CLUT from a PICT file?
  13.         I need gWorlds??
  14.         IP  --> Name translation
  15.         LDEFs - HOW?
  16.         ShowDragHilite -- a real drag?
  17.  
  18.  
  19.  
  20. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  21. (pottier@clipper.ens.fr).
  22.  
  23. The digest is a collection of article threads from the internet newsgroup
  24. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  25. regularly and want an archive of the discussions.  If you don't know what a
  26. newsgroup is, you probably don't have access to it.  Ask your systems
  27. administrator(s) for details.  If you don't have access to news, you may
  28. still be able to post messages to the group by using a mail server like
  29. anon.penet.fi (mail help@anon.penet.fi for more information).
  30.  
  31. Each issue of the digest contains one or more sets of articles (called
  32. threads), with each set corresponding to a 'discussion' of a particular
  33. subject.  The articles are not edited; all articles included in this digest
  34. are in their original posted form (as received by our news server at
  35. nef.ens.fr).  Article threads are not added to the digest until the last
  36. article added to the thread is at least two weeks old (this is to ensure that
  37. the thread is dead before adding it to the digest).  Article threads that
  38. consist of only one message are generally not included in the digest.
  39.  
  40. The digest is officially distributed by two means, by email and ftp.
  41.  
  42. If you want to receive the digest by mail, send email to listserv@ens.fr
  43. with no subject and one of the following commands as body:
  44.     help                        Sends you a summary of commands
  45.     subscribe csmp-digest Your Name    Adds you to the mailing list
  46.     signoff csmp-digest            Removes you from the list
  47. Once you have subscribed, you will automatically receive each new
  48. issue as it is created.
  49.  
  50. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  51. Questions related to the ftp site should be directed to
  52. scott.silver@dartmouth.edu.
  53.  
  54. -------------------------------------------------------
  55.  
  56. >From Said Kobeissi <said.kobeissi@together.org>
  57. Subject: Asynchronous Programming?
  58. Date: 23 Feb 1995 15:57:07 GMT
  59. Organization: TOGETHER INTERNET SERVICES
  60.  
  61. Hi all,
  62.  
  63.   Can anyone give me a pointer to examples or references for
  64. learning how to program asynchronous routines? I want to do
  65. some multitasking but being new to the Mac, have no idea where
  66. to start.
  67.  
  68. Greatly aprpeciate it..
  69.   Said
  70.  
  71. said.kobeissi@together.org
  72.  
  73.  
  74. +++++++++++++++++++++++++++
  75.  
  76. >From oster@netcom.com (David Phillip Oster)
  77. Date: Fri, 24 Feb 1995 02:44:18 GMT
  78. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  79.  
  80. In article <3iib8j$2g0@bristlecone.together.net> Said Kobeissi <said.kobeissi@together.org> writes:
  81. >  Can anyone give me a pointer to examples or references for
  82. >learning how to program asynchronous routines? 
  83.  
  84. look in develop issue 17 (March 1994) "Concurrent programming with the Thread
  85. Manager", particularly "Thread Blocking I/O", on page 90.
  86.  
  87. develop is on the Reference Library volume of the Developer's CD, and is
  88. also available separately from APDA.  I would ignore the article on the
  89. Thread Manager in a recent Mactech.
  90.  
  91. Also, check out a good theory of computing book on state machines. The problem
  92. with using the Thread Manager with asynchronous routines is:
  93.  
  94. o If you use pre-emptive threads, you won't run on a PowerMac, and you'll
  95. still have the usual resource problems that interrupt routines have on the
  96. mac.
  97.  
  98. o If you use only co-operative threads, then your i/o completion routine
  99. will mostly just set some thread to "ready" and it will push things along
  100. at the next co-operative thread Yield(). This can be a problem, since
  101. this thread will be competing for time with your main thread, which is 
  102. calling WaitNextEvent, which takes a larger fraction of a second each time
  103. it is called. In addition, if the user holds the mouse button down over a menu
  104. or a control, WaitNextEvent won't get called until the user lets go, which
  105. can be a _long_ time.
  106.  
  107. - -------- Here is what I do
  108.  
  109. pre-allocate resources, and make a "freelist" of them using the Enqueue()
  110. system call.
  111.  
  112. >From my completion routine, I grab resources with Dequeue(). Enqueue()
  113. and Dequeue() are specifically safe to call at interrupt time.  The system
  114. checks the state of the keyboard and mouse at interrupt time, and Dequeues()
  115. an EventRecord from a low-memory linked list of free event records, fills 
  116. it in, and Enqueues() it on the event queue.  I use a similar technique,
  117. with a private event queue, that I poll at WaitNextEvent time, to see if
  118. the interrupt driven side of my program has any messages for the user 
  119. interface side of the program.
  120.  
  121. My completion routines generally start more async i/o, but they also start
  122. up "deadman" VBL tasks, which if the VBL fires, KillIO()s the async i/o
  123. and enters an error recovery in the completion routine state machine. If the
  124. i/o completes first, the i/o completion routine disables the VBL.
  125. No race condition is possible, since if the i/o has completed, the KillIO
  126. will do nothing, but if the KillIO comes in before the i/o is complete, the
  127. i/o will be cancelled.
  128.  
  129. I'm the only guy in the world with 
  130.  
  131. o a Logitech Cyberman x,y,z,roll,pitch,yaw joysitck,
  132.  
  133. o a Kurta serial tablet,
  134.  
  135. o an X-10 CP290 Home Control interface
  136.  
  137. on my mac, all running off of my own drivers.
  138. -- 
  139. - ------- <mail-to:oster@netcom.com> ----------
  140. There is no sight finer than that of the planet Earth in your rearview mirror.
  141.  
  142.  
  143.  
  144. ---------------------------
  145.  
  146. >From mdg@seas.gwu.edu (Mark D. Gerl)
  147. Subject: Distinguishing QT-compressed PICTs
  148. Date: 24 Feb 1995 05:19:23 GMT
  149. Organization: George Washington University
  150.  
  151. Here is my question:  Without requiring the presence of QT, how do I
  152. determine that a particular PICT file IS QT compressed (so I can skip it
  153. if QT is NOT installed)?  In other words, how do I distinguish a valid
  154. 1-bit B&W pict from a QT-compressed one?
  155.  
  156. Thanks!
  157.  
  158. Mark
  159.  
  160. - --------------------------------------------------------------------------
  161.  Mark D. Gerl        | "The key to immortality is first living a life worth
  162.  mdg@seas.gwu.edu    |  remembering"                    - Brandon Bruce Lee
  163. - --------------------------------------------------------------------------
  164.  
  165. +++++++++++++++++++++++++++
  166.  
  167. >From sardaukar@aol.com (Sardaukar)
  168. Date: 24 Feb 1995 22:22:21 -0500
  169. Organization: America Online, Inc. (1-800-827-6364)
  170.  
  171. >Here is my question:  Without requiring the presence of QT, how do I
  172. >determine that a particular PICT file IS QT compressed (so I can skip it
  173. >if QT is NOT installed)?  In other words, how do I distinguish a valid
  174. >1-bit B&W pict from a QT-compressed one?
  175.  
  176. Straight from d e v e l o p:
  177. The key to your question is "sit in the bottlenecks." If the picture
  178. contains any QuickTime-compressed images, the images will need to pass
  179. through the StdPix bottleneck. This is a new graphics routine introduced
  180. with QuickTime. Unlike standard QuickDraw images, which only call StdBits,
  181. QuickTime-compressed images need to be decompressed first in the StdPix
  182. routine. Then QuickDraw uses StdBits to render the decompressed image. So
  183. swap out theQuickDraw bottlenecks and put some code in the StdPix routine.
  184. If it's called when you call DrawPicture, you know you have a compressed
  185. picture. To determine the type of compression, you can access the image
  186. description using GetCompressedPixMapInfo. The cType field of the
  187. ImageDescription record will give you the codec type. See the
  188. CollectPictColors snippet on this issue's CD and "Inside QuickTime and
  189. Component-Based Managers" in develop Issue 13, specifically pages 46 and
  190. 47, for more information on swapping out the bottlenecks.
  191.  
  192. ---------------------------
  193.  
  194. >From jbeeghly@u.washington.edu (Jeff Beeghly)
  195. Subject: Getting TEHandle from dialog item number
  196. Date: 25 Feb 1995 21:26:09 GMT
  197. Organization: University of Washington
  198.  
  199.  
  200. I have a dialog that contains several TextEdit items.  The items were 
  201. created in ResEdit, not on the fly by calling TENew.
  202.  
  203. My problem:  In the dialog filter I'm writing, I need to be able to 
  204. access several of the TE fields (I need to Activate & DeActivate).
  205.  
  206. I can't just use SelIText & GetIText because I need the TEHandle of a 
  207. particular field.
  208.  
  209. Right now I can access the CURRENT TE field by using
  210. ((DialogPeek )theDialog)->textH, but this only applies to the current field.
  211.  
  212. Ideally, I'd like to find (or create) a call that does
  213.  
  214. theTEHndl = TEHFromDialogNumber(theDialog, theNumber);
  215.  
  216. where theTEHndl is a TEHandle, theDialog is a DialogPtr, and theNumber is 
  217. a short (it's the item number).
  218.  
  219. I have THINK Ref, and I've read through the TextEdit, Dialog Manager, and 
  220. Control manager sections.  The stuff in the TextEdit section all seem to 
  221. require a TEHandle of the item in question, but since I am not creating 
  222. the TE fields on the fly, I don't have the TEHandles.  My goal:  Find out 
  223. how to get a TEHandle from a dialog index number.
  224.  
  225. Any help would be EXTREEMLY helpful at this point....
  226.  
  227. Thanks in advance,
  228.  
  229.  
  230. Jeff
  231.  
  232.  
  233. +++++++++++++++++++++++++++
  234.  
  235. >From Matt Slot <fprefect@umich.edu>
  236. Date: 25 Feb 1995 23:52:02 GMT
  237. Organization: University of Michigan
  238.  
  239. Jeff Beeghly, jbeeghly@u.washington.edu writes:
  240.  > My problem:  In the dialog filter I'm writing, I need to be able to 
  241.  > access several of the TE fields (I need to Activate & DeActivate).
  242.  
  243. There are 2 ways to write dialogs, with ModalDialog() or a modeless dialog
  244. (this includes movable modal for most intents/purposes) using
  245. DialogSelect().
  246. ModalDialog offers a filterProc for you to intercept events, but you can
  247. always return FALSE to let the Dialog Mgr handle it -- but Modal Dialogs
  248. should only need to be activated once! You are not supposed to switch out
  249. of them when they are up. 
  250.  
  251. If you have a modeless dialog, then it may need to be
  252. activated/deactivated
  253. several times across its lifetime. However, DialogSelect() should already
  254. handle (and eat) the activate events. Note that you dont write a filter
  255. function for DialogSelect... you handle it through your main event loop.
  256.  
  257.  
  258.  > I can't just use SelIText & GetIText because I need the TEHandle of a 
  259.  > particular field.
  260.  > 
  261.  > Right now I can access the CURRENT TE field by using
  262.  > ((DialogPeek )theDialog)->textH, but this only applies to the current
  263. field.
  264.  > 
  265.  > Ideally, I'd like to find (or create) a call that does
  266.  > 
  267.  > theTEHndl = TEHFromDialogNumber(theDialog, theNumber);
  268.  > 
  269.  > where theTEHndl is a TEHandle, theDialog is a DialogPtr, and theNumber
  270. is 
  271.  > a short (it's the item number).
  272.  
  273. Each Dialog has only 1 TERec allocated for it because you are only
  274. supposed
  275. to have one active text field in a window. When the user tabs between
  276. items
  277. or clicks in a new text field, the Dialog Mgr resets the ((DialogPeek)
  278. theDialog)->textH field to be a text record for the new active field.
  279.  
  280. Because there is little need to modify the TERec of inactive items, there
  281. is
  282. little way to do this beyond the GetIText(), SetIText(), and SelIText()
  283. functions
  284. provided. If you *need* to, you can twiddle the given TERec, but I have
  285. done
  286. lotsa custom dialog stuff and never needed to.
  287.  
  288.  > I have THINK Ref, and I've read through the TextEdit, Dialog Manager,
  289. and 
  290.  > Control manager sections.  The stuff in the TextEdit section all seem
  291. to 
  292.  > require a TEHandle of the item in question, but since I am not
  293. creating 
  294.  > the TE fields on the fly, I don't have the TEHandles.  My goal:  Find
  295. out 
  296.  > how to get a TEHandle from a dialog index number.
  297.  
  298. Unfortunately TR is not much help, cuz the information is scattered in
  299. bit and
  300. pieces. You might try NIM-Mac Toolbox Essentials... it is a total rewrite
  301. of the
  302. necessary information.
  303.  
  304. Matt
  305.  
  306. +++++++++++++++++++++++++++
  307.  
  308. >From altura@aol.com (ALTURA)
  309. Date: 25 Feb 1995 21:43:34 -0500
  310. Organization: America Online, Inc. (1-800-827-6364)
  311.  
  312. > My goal:  Find out 
  313. > how to get a TEHandle from a dialog index number.
  314.  
  315. The Dialog Manager only creates one TEHandle for the entire dialog.  When
  316. an edit text item is activated, the Dialog Manager munges the TEHandle for
  317. the dialog to use that item's data.  The item_h returned by GetDItem for
  318. each edit text item is merely a handle with text that the Dialog Manager
  319. puts in the TEHandle's hText field.
  320.  
  321. -Jordan
  322.  
  323. +++++++++++++++++++++++++++
  324.  
  325. >From jbeeghly@u.washington.edu (Jeff Beeghly)
  326. Date: 27 Feb 1995 00:32:50 GMT
  327. Organization: University of Washington
  328.  
  329. Matt Slot <fprefect@umich.edu> writes:
  330.  
  331. >There are 2 ways to write dialogs, with ModalDialog() or a modeless dialog
  332. >(this includes movable modal for most intents/purposes) using
  333. >DialogSelect().
  334. >ModalDialog offers a filterProc for you to intercept events, but you can
  335. >always return FALSE to let the Dialog Mgr handle it -- but Modal Dialogs
  336. >should only need to be activated once! You are not supposed to switch out
  337. >of them when they are up. 
  338.  
  339. >If you have a modeless dialog, then it may need to be
  340. >activated/deactivated
  341. >several times across its lifetime. However, DialogSelect() should already
  342. >handle (and eat) the activate events. Note that you dont write a filter
  343. >function for DialogSelect... you handle it through your main event loop.
  344.  
  345.  
  346. I am using a custom filter proc, however, the reason I want to activate & 
  347. de-activate TE items is that I'm creating dialogs that act like the 
  348. standard "Save file" dialog box.
  349.  
  350. In a dialog box I'm working on, there are two lists boxes and two TE 
  351. fields.  Pressing TAB switches the focus.  In my dialog box, it goes TE1, 
  352. TE2, ListBox1, ListBox2.  When LB1 or LB2 have the focus, a rectangle 
  353. outlines the list box (please see NIM, More Toolbox Essentials: List 
  354. Boxes for further info), and I need to de-select the current TE field.
  355.  
  356.  
  357.  
  358. +++++++++++++++++++++++++++
  359.  
  360. >From Matt Slot <fprefect@umich.edu>
  361. Date: 27 Feb 1995 00:49:18 GMT
  362. Organization: University of Michigan
  363.  
  364. Jeff Beeghly, jbeeghly@u.washington.edu writes:
  365.  > I am using a custom filter proc, however, the reason I want to
  366. activate & 
  367.  > de-activate TE items is that I'm creating dialogs that act like the 
  368.  > standard "Save file" dialog box.
  369.  
  370. You should only have to deactivate and then activate the current text
  371. field,
  372. which is accessible thru the textH field of the DialogPeek (the other
  373. field
  374. is already deactivated).
  375.  
  376. Or, you might try to see if you can tweak the textH and editField info
  377. directly, and use it to indicate the current keyboard focus for both
  378. text AND and lists. (My impression is that the Dialog Mgr wont like this,
  379. but it may be worth a shot.)
  380.  
  381. ---------------------------
  382.  
  383. >From Martin Cowley <cowley@sys.uea.ac.uk>
  384. Subject: How to get a CLUT from a PICT file?
  385. Date: 20 Feb 1995 19:32:46 GMT
  386. Organization: BITE Project, UEA
  387.  
  388. I'm putting the finishing touches to a hypermedia system in C++ on Mac
  389. and Windows that uses QuickTime and QuickTime for Windows.  It uses the
  390. QuickTime DisplayPictureFromFile() function to display the picture
  391. straight from disk, rather than reading it into memory first (which is
  392. something I still haven't found a straightforward way of doing).  It sets
  393. up the picture's frame from the information supplied by the
  394. GetPictureFileHeader() function.
  395.  
  396. All my picture files have the same CLUT (optimised with Debabelizer), and
  397. I'd like to be able to set up the CLUT from the PICT file too without
  398. having to read the whole thing into memory first.  Does anyone know of a
  399. good way to do this?  At the moment I'm storing the CLUT as a resource,
  400. but this means that I have to recompile every time my CLUT changes, and
  401. also that I need to store every possible CLUT as a resource.  Reading the
  402. CLUT from the file would make the system far more flexible as it would be
  403. able to deal with new CLUTs without modification.
  404.  
  405. QuickTime for Windows has a  GetPicturePalette() function which extracts
  406. the palette from a memory-resident PICT, but then QTW also has a
  407. GetPictureFromFile() function which sets up a picture in memory from the
  408. disk file.  If it's not possible to get the CLUT from the file on a Mac
  409. then I guess I'll have to read it in first, but how?  The Mac seems to
  410. have no equivalent to QTW's GetPictureFromFile() function, and the only
  411. relevant bit of code I've seen is in the Apple PICT File Format Notes -
  412. it looks pretty horrendous and assumes you want to draw the picture as
  413. you're reading it, which is not what I want to do.
  414.  
  415. Any help on this would be very much appreciated!
  416.  
  417. Thanks in advance,
  418.  
  419. Martin.
  420.  
  421. ____________________________________________
  422.  
  423. Martin Cowley
  424. Senior Research Associate
  425. BITE Project
  426. UEA Norwich
  427. NR4 7TJ
  428. UK
  429.  
  430. Email: cowley@sys.uea.ac.uk
  431. URL  : http://www.sys.uea.ac.uk/acc/photos/cowley.html
  432.  
  433. +++++++++++++++++++++++++++
  434.  
  435. >From english@primenet.com (Lawson English)
  436. Date: 24 Feb 1995 01:18:22 GMT
  437. Organization: Primenet
  438.  
  439. Martin Cowley (cowley@sys.uea.ac.uk) wrote:
  440. : I'm putting the finishing touches to a hypermedia system in C++ on Mac
  441. : and Windows that uses QuickTime and QuickTime for Windows.  It uses the
  442. : QuickTime DisplayPictureFromFile() function to display the picture
  443.  
  444. [snipt]
  445.  
  446. : QuickTime for Windows has a  GetPicturePalette() function which extracts
  447. : the palette from a memory-resident PICT, but then QTW also has a
  448. : GetPictureFromFile() function which sets up a picture in memory from the
  449. : disk file.  If it's not possible to get the CLUT from the file on a Mac
  450. : then I guess I'll have to read it in first, but how?  The Mac seems to
  451. : have no equivalent to QTW's GetPictureFromFile() function, and the only
  452. : relevant bit of code I've seen is in the Apple PICT File Format Notes -
  453. : it looks pretty horrendous and assumes you want to draw the picture as
  454. : you're reading it, which is not what I want to do.
  455.  
  456. What you are looking for is in NIM:Imaging with QUickDraw, pp 7-13&14.
  457.  
  458. Assuming that you've gotten a file reference number for the PICT file:
  459.  
  460. +++++++++++++++++++++++++++
  461. Drawing a Picture Stored in a 'PICT' File
  462.  
  463. Listing 7-2 illustrates an application-defined routine, called 
  464. MyDrawFilePicture, that uses File Manager routines to retrieve a picture 
  465. saved in a 'PICT' file. The MyDrawFilePicture routine takes a file 
  466. reference number as a parameter. 
  467.  
  468. Listing 7-2  Opening and drawing a picture from disk
  469.  
  470. FUNCTION MyDrawFilePicture(pictFileRefNum: Integer; destRect: Rect): OSErr;
  471. CONST
  472.   cPicFileHeaderSize = 512;
  473. VAR
  474.   myPic:        PicHandle;
  475.   dataLength:        LongInt;
  476.   err:        OSErr;
  477. BEGIN      {This listing assumes the current graphics port is set.}
  478.   err := GetEOF(pictFileRefNum,dataLength);      {get file length}
  479.   IF err = noErr THEN BEGIN
  480.     err := SetFPos(pictFileRefNum,fsFromStart,
  481.               cPicFileHeaderSize);   {move past the 512-byte 'PICT' }
  482.                                      { file header}
  483.     dataLength := dataLength - cPicFileHeaderSize;
  484.                         {remove 512-byte }
  485.                         { 'PICT' file header from file length}
  486.     myPic := PicHandle(NewHandle(dataLength)); {allocate picture handle}
  487.     IF (err = noErr) & (myPic <> NIL) THEN BEGIN
  488.       HLock(Handle(myPic));     {lock picture handle before using FSRead}
  489.       err := FSRead(pictFileRefNum,dataLength,Ptr(myPic^));    {read file}
  490.       HUnlock(Handle(myPic));   {unlock picture handle after using FSRead}
  491.       MyAdjustDestRect(myPic,destRect);   {see Listing 7-7 on page 7-18}
  492.       DrawPicture(myPic,destRect);
  493.       IF QDError <> noErr THEN
  494.         ; {likely error is that there is insufficient memory}
  495.       KillPicture(myPic);
  496.     END;
  497.   END;
  498.   MyDrawFilePicture := err;
  499. END;
  500.  
  501. In code not shown in Listing 7-2, this application uses the File Manager 
  502. procedure StandardGetFile to display a dialog box that asks the user for 
  503. the name of a 'PICT' file; using the file system specification record 
  504. returned by StandardGetFile, the application calls the File Manager 
  505. function FSpOpenDF to return a file reference number for the file. The 
  506. application then passes this file reference number to MyDrawFilePicture.
  507. Because every 'PICT' file contains a 512-byte header for application-
  508. specific use, MyDrawFilePicture uses the File Manager function SetFPos 
  509. to skip past this header information. The MyDrawFilePicture function then 
  510. uses the File Manager function FSRead to read the file's remaining 
  511. bytes -those of the Picture record- into memory. 
  512. The MyDrawFilePicture function creates a handle for the buffer into which 
  513. the Picture record is read. Passing this handle to the DrawPicture 
  514. procedure, MyDrawFilePicture is able to replay onscreen the commands 
  515. stored in the Picture record.
  516. For large 'PICT' files, it is useful to spool the picture data from disk as 
  517. necessary instead of reading all of it directly into memory. 
  518. +++++++++++++++++++++++++++++++++++++++++++++
  519.  
  520. Once you have the PICT file in memory, you can use the GetPictInfo 
  521. function to gather info about a single picture:
  522.  
  523. (NIM:Imaging, pp 7-47&48)
  524. ++++++++++++++++++++++++++++++++++++++++
  525. GetPictInfo
  526.  
  527. Use the GetPictInfo function to gather information about a single picture.
  528. FUNCTION GetPictInfo (thePictHandle: PicHandle; 
  529.                VAR thePictInfo: PictInfo; verb: Integer; 
  530.                colorsRequested: Integer; 
  531.                colorPickMethod: Integer; 
  532.                version: Integer): OSErr;
  533.  
  534. thePictHandle: A handle to a picture. 
  535. thePictInfo: A pointer to a PictInfo record, which will hold information 
  536. about the picture. The PictInfo record is described on page 7-32.
  537. verb  A value indicating what type of information you want GetPictInfo to 
  538. return in the PictInfo record. You can use any or all of the following 
  539. constants or the sum of the integers they represent:
  540.  
  541.         CONST
  542.         returnColorTable            = 1;    {return a ColorTable record}
  543.         returnPalette            = 2;    {return a Palette record}
  544.         recordComments            = 4;    {return comment information}
  545.         recordFontInfo            = 8;    {return font information}
  546.         suppressBlackAndWhite
  547.                     = 16;    {don't include black and }
  548.                         { white with returned colors}
  549. ++++++++++++++++++++++
  550.  
  551. For more info, look at NIM:Imaging, chapter 7.
  552.  
  553. Hope that this helps...
  554.  
  555.  
  556. --
  557. - -----------------------------------------------------------------------------
  558. Lawson English                            __  __     ____  ___       ___ ____
  559. english@primenet.com                     /__)/__) / / / / /_  /\  / /_    /
  560.                                         /   / \  / / / / /__ /  \/ /___  /
  561. - -----------------------------------------------------------------------------
  562.  
  563. ---------------------------
  564.  
  565. >From TICS28@waccvm.corp.mot.com (Alan Long)
  566. Subject: I need gWorlds??
  567. Date: 22 Feb 1995 06:14:10 MST
  568. Organization: Motorola
  569.  
  570.      I'm new to Mac programming, and found during development of my first
  571. (simple!) application that updating the screen after being revealed from
  572. behind another window is a real pain.  It's difficult to keep track of
  573. what should be on-screen and what should not, at any point in time, so my
  574. screen update function became almost as complicated as the rest of the
  575. program.
  576.  
  577.      Is the answer to use the famous gWorlds (I haven't yet crossed
  578. swords with these)?  I get the feeling that it is preferable to always
  579. write to an off-screen gWorld and then use CopyBits to write to my
  580. visible screen.  A screen update can then presumably be accomplished by
  581. simply copying from off-screen.
  582.  
  583.      Is this the best general solution to my updating problem?
  584.  
  585. Regards,
  586. Alan
  587.  
  588. +++++++++++++++++++++++++++
  589.  
  590. >From Gordon Graber <gg4921s@acad.drake.edu>
  591. Date: 22 Feb 1995 14:51:57 GMT
  592. Organization: Drake University
  593.  
  594. In article <1995Feb22.132656.21397@schbbs.mot.com> Alan Long,
  595. TICS28@waccvm.corp.mot.com writes:
  596. >behind another window is a real pain.  It's difficult to keep track of
  597. >what should be on-screen and what should not, at any point in time, so my
  598. >screen update function became almost as complicated as the rest of the
  599. >program.
  600.  
  601. Perhaps you, like I, are making the the situation too complicated.  I
  602. have found that the easiest way the update a window is to draw the entire
  603. window.  When issuing your drawing calls, bracket them with
  604. the BeginUpdate/EndUpdate statements.  This will allow the system to
  605. handle exactly what part of the window actually gets drawn into.
  606. You need not be concerned with what part of a window is, say, revealed,
  607. because the update mechinism handles that for you
  608.   GWorlds are not going to help you in this respect.  What gworlds will
  609. allow you to do is set up your window, offscreen.  When  you copy the
  610. offscreen gworld to your window, your window is drawn
  611. "at once", without the user seeing all the drawing calls executing that
  612. comprise the graphics inside your window.  Since you have constucted the
  613. "content" of your window offscreen, and then copy that offscreen
  614. "content" to your "visible" window, the user only sees one "drawing
  615. command".
  616.   Again it is the update mechanism that ensures that only the parts of
  617. the window that need updating, i.e. the parts that have been uncovered,
  618. are actually drawn into.
  619.   Hope it helps!
  620. Gordon Graber: gg4921s@acad.drake.edu
  621.  
  622. +++++++++++++++++++++++++++
  623.  
  624. >From ssample1@cc.swarthmore.edu (Stephen &roo Sample)
  625. Date: Wed, 22 Feb 1995 12:34:05 -0500
  626. Organization: RadioƖcular Stereo Systems
  627.  
  628. In article <3ifj2d$ad3@dunix.drake.edu>, Gordon Graber
  629. <gg4921s@acad.drake.edu> wrote:
  630.  
  631. > Perhaps you, like I, are making the the situation too complicated.  I
  632. > have found that the easiest way the update a window is to draw the entire
  633. > window.  When issuing your drawing calls, bracket them with
  634. > the BeginUpdate/EndUpdate statements.  This will allow the system to
  635. > handle exactly what part of the window actually gets drawn into.
  636. > You need not be concerned with what part of a window is, say, revealed,
  637. > because the update mechinism handles that for you
  638.  
  639. The other thing you can do is use the visRgn of the window
  640. (window->visRgn) as the mask region when you update with CopyBits. This is
  641. probably marginally faster than the method described above (fewer calls
  642. and less memory being thrown around), but I don't have any numbers.
  643.  
  644.  
  645. Ta,
  646.    -Stephen
  647.  
  648. +++++++++++++++++++++++++++
  649.  
  650. >From blm@chinook.halcyon.com (Brian L. Matthews)
  651. Date: 22 Feb 1995 17:58:10 GMT
  652. Organization: NW NEXUS, Inc. -- Internet Made Easy (206) 455-3505
  653.  
  654. In article <1995Feb22.133656.21633@schbbs.mot.com>,
  655. Alan Long <TICS28@waccvm.corp.mot.com> wrote:
  656. |Is this [GWorlds] the best general solution to my updating problem?
  657.  
  658. Without knowing more about your application it's hard to say, but in
  659. general, the answer is probably not.
  660.  
  661. First, you only need to keep track of what's in the window, because
  662. BeginUpdate will cause your drawing to be clipped to the region of your
  663. window that needs updating.  In fact, you could draw all your data, and
  664. Quickdraw will automatically clip things correctly.  Of course if you've
  665. got a lot of things to draw, trap overhead may kill you, so you could
  666. compare each item's bounds to the clip region yourself.
  667.  
  668. Second, keeping GWorlds may take a *lot* of memory.  Consider a full color
  669. window on a 1024x768, 16bit screen.  If the window is zoomed to full size,
  670. a GWorld would probably be around 960x750x2 or 1.44Meg.  And a 1024x768
  671. screen isn't the biggest available, and with multiple monitors your window
  672. could be much bigger.  And of course that's just one window, if you support
  673. multiple windows (which, in general, you should), you'll need a GWorld
  674. for each.  Pretty soon your memory requirements will exceed even those
  675. of Microsoft apps. :-)
  676.  
  677. Before resorting to GWorlds, look at the design of your app and how you
  678. keep track of your data.  Some judicious redesign may solve your problem.
  679.  
  680. Brian
  681. --
  682. Brian L. Matthews                    blm@halcyon.com
  683.   You can't have a syntax error with a hammer.
  684.  
  685. +++++++++++++++++++++++++++
  686.  
  687. >From Gordon Graber <gg4921s@acad.drake.edu>
  688. Date: 22 Feb 1995 19:05:04 GMT
  689. Organization: Drake University
  690.  
  691. In article <ssample1-2202951234050001@wallach.swarthmore.edu> Stephen
  692. &roo Sample, ssample1@cc.swarthmore.edu writes:
  693. >The other thing you can do is use the visRgn of the window
  694. >(window->visRgn) as the mask region when you update with CopyBits. This
  695. is
  696. >probably marginally faster than the method described above (fewer calls
  697. >and less memory being thrown around), but I don't have any numbers.
  698.  
  699.   Isn't this the region that the system uses through the update
  700. mechanism, anyway?  Or are you helping the system out, in a sense, by
  701. setting this region manually?  Can you elaborate?
  702.  
  703. Thanks,
  704. Gordon Graber:  gg4921s@acad.drake.edu
  705.  
  706. +++++++++++++++++++++++++++
  707.  
  708. >From jwbaxter@olympus.net (John W. Baxter)
  709. Date: Wed, 22 Feb 1995 13:08:32 -0800
  710. Organization: Internet for the Olympic Peninsula
  711.  
  712. In article <1995Feb22.133656.21633@schbbs.mot.com>,
  713. TICS28@waccvm.corp.mot.com (Alan Long) wrote:
  714.  
  715. >      I'm new to Mac programming, and found during development of my first
  716. > (simple!) application that updating the screen after being revealed from
  717. > behind another window is a real pain.  It's difficult to keep track of
  718. > what should be on-screen and what should not, at any point in time, so my
  719. > screen update function became almost as complicated as the rest of the
  720. > program.
  721.  
  722. gWorlds aside, the general paradigm is to do ALL drawing in response to
  723. update events ("live" scrolling in its various forms being a key
  724. exception).  That means your app needs to keep track of what should be
  725. drawn where (which is fairly natural:  if it were to read the same data
  726. >From a file it would have to know what should be drawn where).  Then upon
  727. update, the easy way is to draw everything.  Slightly more complex (and
  728. perhaps lots faster) is to draw only things which intersect the area of
  729. the window being drawn.  And using gWorlds is a little more complex, but
  730. in many ways better (the user doesn't see things being drawn--she sees the
  731. result).
  732.  
  733. >      Is the answer to use the famous gWorlds (I haven't yet crossed
  734. > swords with these)?  I get the feeling that it is preferable to always
  735. > write to an off-screen gWorld and then use CopyBits to write to my
  736. > visible screen.  A screen update can then presumably be accomplished by
  737. > simply copying from off-screen.
  738. >      Is this the best general solution to my updating problem?
  739.  
  740. Often, yes.  Not always.
  741.  
  742. Suggest you study the code samples (unfortunately, that means the more
  743. complex ones).
  744.  
  745.    --John
  746.  
  747. -- 
  748. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  749.        Isn't C fun?
  750.    jwbaxter@pt.olympus.net
  751.  
  752. +++++++++++++++++++++++++++
  753.  
  754. >From Bruce@hoult.actrix.gen.nz (Bruce Hoult)
  755. Date: Fri, 24 Feb 1995 19:31:29 +1300 (NZDT)
  756. Organization: (none)
  757.  
  758. TICS28@waccvm.corp.mot.com (Alan Long) writes:
  759. >      I'm new to Mac programming, and found during development of my first
  760. > (simple!) application that updating the screen after being revealed from
  761. > behind another window is a real pain.  It's difficult to keep track of
  762. > what should be on-screen and what should not, at any point in time, so my
  763. > screen update function became almost as complicated as the rest of the
  764. > program.
  765. >      Is the answer to use the famous gWorlds (I haven't yet crossed
  766. > swords with these)?  I get the feeling that it is preferable to always
  767. > write to an off-screen gWorld and then use CopyBits to write to my
  768. > visible screen.  A screen update can then presumably be accomplished by
  769. > simply copying from off-screen.
  770. >      Is this the best general solution to my updating problem?
  771.  
  772. The general solution is to maintain some sort of data structure that
  773. describes the screen contents, and have a single Draw() function that
  774. draws the whole mess (or better: just the contents of a rectangular
  775. area.
  776.  
  777. This should usually be the *only* place in your program that you draw
  778. the contents of your window.  Anywhere else that you really think you want
  779. to change what's on the screen, you should just call InvalidRect() on the
  780. area you want to draw into, and wait for the system to send you an update
  781. event.
  782.  
  783. This breaks down for things like feedback on mouse tracking, and other
  784. animation, but is a good general rule, to br broken when needed.
  785.  
  786. Now, the data structure that you create to describe the screen's contents
  787. will usually be something like a list of the objects on the screen, but
  788. in some cases you might in fact want to have this data structure be an
  789. off-screen GWorld.  The reason for doing this would usually be that
  790. redrawing the screen takes too long otherwise, and not because it is
  791. too complicated.  If you can draw it in the first place then it's usually
  792. not too much harder to do it so you draw it on demand.
  793.  
  794. Of course, something that is very complicated to draw is probably also
  795. slow to draw.  But we're talking *really* complicated -- like a 3D render
  796. of a complex scene -- before that's an issue.
  797.  
  798. Bear in mind also that an offscreen GWorld can solve the window revealing
  799. problem, but it doesn't solve the window resize problem, or the window
  800. scrolling problem unless the offscreen GWorld is the size of the entire
  801. document, not just the size of the window.
  802.  
  803. A Draw() routine that can on demand draw any rectangle from your document,
  804. OTOH, solves all these problems, and that is exactly how application
  805. frameworks such as MacApp and TCL and PowerPlant do window revealing and
  806. resizing and scrolling (and printing, too).  All by calling a single
  807. user-supplied Draw() routine to draw an appropriate rectangle.
  808.  
  809. Hope this helps.
  810.  
  811. -- Bruce
  812.  
  813. ---------------------------
  814.  
  815. >From giampaol@snowhite.eeap.cwru.edu (Jude Giampaolo)
  816. Subject: IP  --> Name translation
  817. Date: Sun, 26 Feb 1995 12:33:57 -0500
  818. Organization: CWRU Amoeba Project
  819.  
  820. I'm looking for a code example that takes an IP address and returns the
  821. hostname. I would prefer Pascal, but C would be ok too.
  822.  
  823. Thanks....
  824.  
  825. -- 
  826. Jude Giampaolo              Case Western Reserve University
  827. Electrical Engineering      'There's not much to see actually,
  828. and Applied Physics         we're inside a Chinese dragon...'
  829. jcg8@po.cwru.edu            giampaol@snowhite.eeap.cwru.edu
  830.  
  831. +++++++++++++++++++++++++++
  832.  
  833. >From chris-b@cs.auckland.ac.nz (chris-b)
  834. Date: Mon, 27 Feb 1995 18:37:58 +1200
  835. Organization: HyperMedia Unit, Comp Sci, Auckland University
  836.  
  837. In article <giampaol-2602951233570001@caffeine.student.cwru.edu>,
  838. giampaol@snowhite.eeap.cwru.edu (Jude Giampaolo) wrote:
  839.  
  840. >I'm looking for a code example that takes an IP address and returns the
  841. >hostname. I would prefer Pascal, but C would be ok too.
  842.  
  843. Here's some C to do the job. Read "MacTCP Programmer's Guide" for more info.
  844. Most error handling is removed for clarity.
  845.  
  846.  
  847. #include <MacTCP.h>
  848.  
  849. OSErr           Err;
  850. ip_addr         IPAddr;
  851. SInt16          IOResult;
  852. hostInfo        HInfo;
  853.  
  854. ////////////////////////////////////////
  855. //Get IP address
  856.  
  857.     IPAddr = ??;
  858.  
  859. ////////////////////////////////////////
  860. //Open DNR
  861.  
  862.     Err = OpenResolver(nil);
  863.     if (Err != noErr)
  864.     {
  865.     }
  866.  
  867. ////////////////////////////////////////
  868. //Lookup our machine name on net
  869.  
  870.     IOResult = inProgress;
  871.     Err =
  872. AddrToName(IPAddr,&HInfo,(ResultProcPtr)DNRResultProc,(char*)&IOResult);
  873.     if (Err == cacheFault)
  874.     {
  875.         WaitFor(&IOResult);
  876.         Err = HInfo.rtnCode;
  877.     }
  878.  
  879.     switch (Err)
  880.     {
  881.         case noErr:
  882. //Machine name (CString) in HInfo.cname 
  883.             break;
  884.  
  885.         case noNameServer:
  886.         case authNameErr:
  887.         case noAnsErr:
  888.         case dnrErr:
  889.         case outOfMemory:
  890.             Err = CloseResolver();
  891.             break;
  892.  
  893.         default:
  894.             Err = CloseResolver();
  895.             break;
  896.    }
  897.  
  898. ////////////////////////////////////////
  899. //Close DNR
  900.  
  901.     Err = CloseResolver();
  902.     if (Err != noErr)
  903.     {
  904.     }
  905.  
  906. ////////////////////////////////////////
  907.  
  908. Chris B
  909. - ---------------------------------------------------------------------
  910. NewZealand:AucklandUniversity:ComputerScience:HyperMediaUnit:ChrisBurns
  911. Internet: chris-b@cs.auckland.ac.nz
  912. Phone:    +64 9 373-7599 x6194
  913. Fax:      +64 9 373-7453                         Async, therefore I am.
  914. - ---------------------------------------------------------------------
  915.  
  916. ---------------------------
  917.  
  918. >From berntson@oeb.harvard.edu (Glenn M. Berntson)
  919. Subject: LDEFs - HOW?
  920. Date: Mon, 20 Feb 1995 08:50:51 -0400
  921. Organization: Harvard University
  922.  
  923. I've been playing with lists for a while and have heard mention of LDEFs
  924. to add functionality to lists.
  925.  
  926. How do they work?  Where can I find informtion on how to create and use an LDEF?
  927.  
  928. Any information would be greatly appreciated.
  929.  
  930. Thanks
  931.  
  932. Glenn
  933.  
  934. +++++++++++++++++++++++++++
  935.  
  936. >From Matt Slot <fprefect@engin.umich.edu>
  937. Date: 20 Feb 1995 16:29:08 GMT
  938. Organization: University of Michigan
  939.  
  940. Glenn M. Berntson, berntson@oeb.harvard.edu writes:
  941.  > Where can I find informtion on how to create and use an LDEF?
  942.  
  943. Look at your local Sumex mirror for a file called "sample-ldefs",
  944. somewhere in the depths of the "dev" directory.
  945.  
  946. Matt
  947.  
  948. +++++++++++++++++++++++++++
  949.  
  950. >From kurisuto@babel.ling.upenn.edu (Sean Crist)
  951. Date: 20 Feb 1995 22:41:14 GMT
  952. Organization: University of Pennsylvania, Linguistics Department
  953.  
  954. In article <berntson-2002950850510001@bloeb-mac8.harvard.edu>,
  955. Glenn M. Berntson <berntson@oeb.harvard.edu> wrote:
  956. >I've been playing with lists for a while and have heard mention of LDEFs
  957. >to add functionality to lists.
  958. >
  959. > How do they work?  Where can I find informtion on how to create and use
  960. > an LDEF? 
  961.  
  962. The idea of definition functions is common to several of the Toolbox
  963. managers: the menu manager uses MDEFs to draw menus; the window manager
  964. uses WDEFs to draw windows; the list manager uses LDEFs to draw cells in
  965. lists.  For example, the menu manager doesn't do the actual drawing of
  966. menus itself; instead, it calls an MDEF at the appropriate time to draw a
  967. menu.  There's the standard MDEF that draws normal text menus, but you can
  968. write your own MDEF for, say, a tools menu or a patterns menu.
  969.  
  970. Likewise with the List Manager.  The List Manager figures out how which
  971. cell you've clicked in, what the scroll bars should be doing, etc, but the
  972. actual drawing of the cells is done by the LDEF.  The standard LDEF draws
  973. strings, but you can write an LDEF to draw any kind of cell you like (lists
  974. of icons, etc.)  The description in OldIM IV is pretty clear on how to do
  975. this (I have no idea where it is in NIM).
  976.  
  977. Apple's original idea was that the LDEF would be a separate resource which
  978. would contain all the code to draw a cell, but the problem is that such
  979. things are annoying to debug, since you can't use your programming
  980. environment to step through them as you can with regular application code.
  981. What a lot of people do is just to make a little _stub_ of an LDEF which
  982. only contains a machine instruction to jump into your main code; then, you
  983. can do your debugging as usual within your program and can also access all
  984. of your program's globals from within your pseudo-LDEF, which you can't do
  985. >From a real LDEF  (Usual caveats about self-modifying code apply).  If you
  986. want details on how to do this, write me, or I can post some Pascal code if
  987. there's interest.
  988.  
  989.   \/ __ __    _\_     --Sean Crist  (kurisuto@unagi.cis.upenn.edu)
  990.  ---  |  |    \ /     For a free copy of the Bill of Rights, finger
  991.   _| ,| ,|   -----       this account.
  992.   _| ,| ,|    [_]     Q: What do Standard Oil, AT&T, and Microsoft have in
  993.    |  |  |    [_]        common?   A:  Nothing... yet.
  994.  
  995.  
  996. +++++++++++++++++++++++++++
  997.  
  998. >From cwatson@cam.org (Chris Watson)
  999. Date: Wed, 22 Feb 1995 16:23:27 -0500
  1000. Organization: Communications Accessibles Montreal, Quebec Canada
  1001.  
  1002. In article <berntson-2002950850510001@bloeb-mac8.harvard.edu>,
  1003. berntson@oeb.harvard.edu (Glenn M. Berntson) wrote:
  1004.  
  1005. > I've been playing with lists for a while and have heard mention of LDEFs
  1006. > to add functionality to lists.
  1007. > How do they work?  Where can I find informtion on how to create and use
  1008. an LDEF?
  1009. > Any information would be greatly appreciated.
  1010.  
  1011.  
  1012. An LDEF is a List Definition, it's just a little piece of code that
  1013. controls how items in a list of drawn, and highlighted...
  1014.  
  1015. For example, standard file uses a custom LDEF so those icons can be drawn
  1016. next to the file name.
  1017.  
  1018. You can get info in NIM:More Mac ToolBox, in the List Manager section...
  1019.  
  1020.  
  1021. .:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::.
  1022. |    Chris Watson                                                   |
  1023. |    cwatson@cam.org            Hooked on foniks werkes four me!    |
  1024. |    Montreal, Canada                                               |
  1025. i:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::i
  1026.  
  1027. ---------------------------
  1028.  
  1029. >From Carl R. Osterwald <carl_osterwald@nrel.gov>
  1030. Subject: ShowDragHilite -- a real drag?
  1031. Date: Wed, 15 Feb 1995 16:16:53 GMT
  1032. Organization: National Renewable Energy Laboratory
  1033.  
  1034. The HIG for the drag manager states that a window which will be the drop
  1035. location of a drag should be highlighted when the mouse is inside that
  1036. window.  To that end, ShowDragHilite is provided to perform this
  1037. function.  Unfortunately, it only seems to work when the region to be
  1038. highlighted is mostly white (such as Finder windows), or if the bit
  1039. depth is 1 (in which case it inverts pixels).  If graphics are
  1040. displayed in the region to be highlighted (such as when a pix map is
  1041. being displayed), ShowDragHilite does nothing.  This behaviour does not
  1042. seem to be documented in the programmer's guide.
  1043.  
  1044. Also, if scrolling is to take place, one is supposed to call
  1045. DragPreScroll and DragPostScroll so that the highlighting can be erased
  1046. before scrolling takes place, and then restored afterwards.  It has
  1047. been my experience that these routines may be buggy in that in certain
  1048. scrolling situations, the highlighting is not erased properly and you
  1049. end up with a series of bars running across your nice clean window. 
  1050. This seems to happen about 5% of the time.
  1051.  
  1052. The only solution I can see is to dedicate a 3-pixel border around the
  1053. outside the display portion of the window for drag highlighting (inside
  1054. of the scroll bars, of course).  Doing this also gets around the
  1055. scrolling problem because the highlighting never has to be erased.
  1056.  
  1057. In summary, it would seem that the drag manager was designed and
  1058. optimized for the Finder and displays of text, not graphics.
  1059. Any comments?
  1060.  
  1061. +++++++++++++++++++++++++++
  1062.  
  1063. >From blm@coho.halcyon.com (Brian L. Matthews)
  1064. Date: 16 Feb 1995 08:20:00 GMT
  1065. Organization: NW NEXUS, Inc. -- Internet Made Easy (206) 455-3505
  1066.  
  1067. In article <AB677705AF013448@cro.nrel.gov>,
  1068. Carl R. Osterwald  <carl_osterwald@nrel.gov> wrote:
  1069. |Unfortunately, it [ShowDragHilite] only seems to work when the region to be
  1070. |highlighted is mostly white (such as Finder windows), or if the bit
  1071. |depth is 1 (in which case it inverts pixels).
  1072.  
  1073. It actually works, it just doesn't look that way. :-)  ShowDragHilite sets
  1074. hilite mode and inverts the region.  This means that in a multi-bit
  1075. environment, any pixel that is the background color (white, unless you've
  1076. changed it) is replaced with the hilite color (normally set via the Color
  1077. control panel).  So if your window is completely filled with non-white
  1078. (or non-background color) pixels, ShowDragHilite will appear to do nothing.
  1079.  
  1080. |Also, if scrolling is to take place, one is supposed to call
  1081. |DragPreScroll and DragPostScroll so that the highlighting can be erased
  1082. |before scrolling takes place, and then restored afterwards.  It has
  1083. |been my experience that these routines may be buggy in that in certain
  1084. |scrolling situations
  1085.  
  1086. They use updateRgn so if you're doing something strange with it, or not
  1087. calling BeginUpdate/EndUpdate or ScrollRect in the normal fashion, it may
  1088. not work.  I've never seen a problem with it though.
  1089.  
  1090. |The only solution I can see is to dedicate a 3-pixel border around the
  1091. |outside the display portion of the window for drag highlighting (inside
  1092. |of the scroll bars, of course).  Doing this also gets around the
  1093. |scrolling problem because the highlighting never has to be erased.
  1094.  
  1095. Or you could overwrite the outer 3 pixels with the diagonal stripes pattern
  1096. or draw in the hilight color directly (instead of just inverting in the
  1097. hilite mode).  If your window can contain any colors, then it will always
  1098. be possible to construct a graphic that is unchanged by any hiliting in
  1099. the window itself.
  1100.  
  1101. Hmm, just had a thought.  Maybe you could use a set of diagonal patterns
  1102. to make a "marching ants" hilighting.  I believe the Drag and Drop HIG
  1103. mentions "marching ants" marquees for when a simple 50% gray pattern outline
  1104. might not be distinguishable from the stuff in the window, so it would make
  1105. sense to use a similar thing when ShowDrawHilite hilighting might not be
  1106. distinguishable from the contents of the window.  I'll have to remember
  1107. that. :-)
  1108.  
  1109. |In summary, it would seem that the drag manager was designed and
  1110. |optimized for the Finder and displays of text, not graphics.
  1111. |Any comments?
  1112.  
  1113. ShowDragHilite and friends provide a simple way to get the standard behavior
  1114. when your window contains some stuff over the background color, which is
  1115. pretty common.  If you have something different, you may not be able to use
  1116. the drag manager provided routines for scrolling and highlighting.  Think of
  1117. ShowDragHilite and friends as helper functions that provide the "90%"
  1118. behavior.  If you need the "10%" behavior, you have all of Quickdraw to fall
  1119. back on.
  1120.  
  1121. Brian
  1122. --
  1123. Brian L. Matthews                    blm@halcyon.com
  1124.   You can't have a syntax error with a hammer.
  1125.  
  1126. +++++++++++++++++++++++++++
  1127.  
  1128. >From Malcolm Pradhan <pradhan@camis.stanford.edu>
  1129. Date: 16 Feb 1995 17:09:18 GMT
  1130. Organization: Section on Medical Informatics, Stanford University
  1131.  
  1132. In article <AB677705AF013448@cro.nrel.gov> Carl R. Osterwald,
  1133. carl_osterwald@nrel.gov writes:
  1134. >Also, if scrolling is to take place, one is supposed to call
  1135. >DragPreScroll and DragPostScroll so that the highlighting can be erased
  1136. >before scrolling takes place, and then restored afterwards.  It has
  1137. >been my experience that these routines may be buggy in that in certain
  1138. >scrolling situations, the highlighting is not erased properly and you
  1139. >end up with a series of bars running across your nice clean window. 
  1140. >This seems to happen about 5% of the time
  1141.  
  1142.  I also thought this was the case when I was getting all sorts of
  1143. junk thanks to these calls. I was even more suspicious when I discovered
  1144. that the Finder doesn't use these calls, it erases the DragHilite and
  1145. redraws it each time. Unusually ugly for the Finder.
  1146.  
  1147.  However, after I finished my app I have not had this trouble. It seems
  1148. that the DragPre/PostScroll are easily confused, for example during
  1149. debugging. I'm not convinced that these are buggy in normal use but
  1150. they aren't reliable during development.
  1151.  
  1152.  
  1153.  Regards,
  1154.  Malcolm
  1155.  
  1156. +++++++++++++++++++++++++++
  1157.  
  1158. >From Carl R. Osterwald <carl_osterwald@nrel.gov>
  1159. Date: Thu, 16 Feb 1995 16:22:46 GMT
  1160. Organization: National Renewable Energy Laboratory
  1161.  
  1162. In article <3hv1rg$blj@news1.halcyon.com> Brian L. Matthews,
  1163. blm@coho.halcyon.com writes:
  1164.  
  1165. >They use updateRgn so if you're doing something strange with it, or not
  1166. >calling BeginUpdate/EndUpdate or ScrollRect in the normal fashion, it
  1167. >may not work.  I've never seen a problem with it though.
  1168.  
  1169. This is probably what I am seeing--I do have to monkey with the 
  1170. updateRgn.
  1171.  
  1172. >Or you could overwrite the outer 3 pixels with the diagonal stripes
  1173. >pattern or draw in the hilight color directly (instead of just
  1174. >inverting in the hilite mode).  If your window can contain any colors,
  1175. >then it will always be possible to construct a graphic that is
  1176. >unchanged by any hiliting in the window itself.
  1177.  
  1178. ShowDragHilite uses only a 2 pixel outline, so I just inset the graphic
  1179. display area by this amount. The appearance of a 2 pixel border around
  1180. the content is barely noticeable, plus it avoids the scrolling problem,
  1181. so I chose this solution. Also, the time/memory it would take to redraw
  1182. window portions obliterated by the highlighting would be unacceptable
  1183. in my case.
  1184.  
  1185. >Hmm, just had a thought.  Maybe you could use a set of diagonal
  1186. >patterns to make a "marching ants" hilighting.  I believe the Drag and
  1187. >Drop HIG mentions "marching ants" marquees for when a simple 50% gray
  1188. >pattern outline might not be distinguishable from the stuff in the
  1189. >window, so it would make sense to use a similar thing when
  1190. >ShowDrawHilite hilighting might not be distinguishable from the
  1191. >contents of the window.  I'll have to remember that. :-)
  1192.  
  1193. Because I already have a marching ants border, the pattern was still
  1194. (accidently) set to this pattern when I called ShowDragHilite, so I saw
  1195. an effect similar to this.  I didn't like it because it is very
  1196. different from what one sees in the Finder.
  1197.  
  1198. >|In summary, it would seem that the drag manager was designed and
  1199. >|optimized for the Finder and displays of text, not graphics.
  1200. >|Any comments?
  1201. >
  1202. >ShowDragHilite and friends provide a simple way to get the standard
  1203. >behavior when your window contains some stuff over the background
  1204. >color, which is pretty common.  If you have something different, you
  1205. >may not be able to use the drag manager provided routines for
  1206. >scrolling and highlighting.  Think of ShowDragHilite and friends as
  1207. helper functions that provide the "90%" behavior.  If you need the
  1208. >"10%" behavior, you have all of Quickdraw to fall back on.
  1209.  
  1210. I agree.
  1211.  
  1212. +++++++++++++++++++++++++++
  1213.  
  1214. >From blm@coho.halcyon.com (Brian L. Matthews)
  1215. Date: 17 Feb 1995 18:35:43 GMT
  1216. Organization: NW NEXUS, Inc. -- Internet Made Easy (206) 455-3505
  1217.  
  1218. In article <AB68C9E683023448@cro.nrel.gov>,
  1219. Carl R. Osterwald  <carl_osterwald@nrel.gov> wrote:
  1220. |ShowDragHilite uses only a 2 pixel outline, so I just inset the graphic
  1221. |display area by this amount.
  1222. |Because I already have a marching ants border, the pattern was still
  1223. |(accidently) set to this pattern when I called ShowDragHilite, so I saw
  1224. |an effect similar to this.  I didn't like it because it is very
  1225. |different from what one sees in the Finder.
  1226.  
  1227. Although I haven't tried it, this would be my concern too, that it's
  1228. different enough that it might not be obvious that it means the same as
  1229. the highlight color border.  I agree that the 2 pixel border is the
  1230. way to go.  As a bonus, it probably helps set off the graphic from the
  1231. window even when the window isn't drag hilited.
  1232.  
  1233. Brian
  1234. --
  1235. Brian L. Matthews                    blm@halcyon.com
  1236.   You can't have a syntax error with a hammer.
  1237.  
  1238. +++++++++++++++++++++++++++
  1239.  
  1240. >From devans@apple.com (Dave Evans)
  1241. Date: 23 Feb 1995 09:45:22 GMT
  1242. Organization: Apple Computer, Inc.
  1243.  
  1244. > > ... To that end, ShowDragHilite is provided to perform this
  1245. > >function.  Unfortunately, it only seems to work when the region to be
  1246. > >highlighted is mostly white ...
  1247. > >
  1248. > >Also, if scrolling is to take place, one is supposed to call
  1249. > >DragPreScroll and DragPostScroll so that the highlighting can be erased
  1250. > >before scrolling takes place, and then restored afterwards.  It has
  1251. > >been my experience that these routines may be buggy ...
  1252.  
  1253. Hello,
  1254. Let me answer some comments about the DragHilite routines in the Drag 
  1255. Manager toolbox.  First, the general rule for drag hilites is to provide
  1256. the best feedback for your users.  You may need to customize the Drag
  1257. and Drop Guidelines to fit your interface, and in some cases the
  1258. DragHilite routines may not meet your needs.
  1259.  
  1260. Specifically, the ShowDragHilite routine will only work correctly if
  1261. the window's background color is white or a very light gray.  On a darker
  1262. gray background, I recommend you draw our own drag hilite in a very dark
  1263. grey and restore to your background color manually.  This should be
  1264. easy to implement.
  1265.  
  1266. The DragPreScroll and DragPostScroll routines should work fine.  Be
  1267. careful with your port's clip region -- if you modify this during
  1268. your scroll the drag scroll routines might leave bits behind.
  1269.  
  1270. For best scroll appearance, however, I recommend using an offscreen
  1271. port for your drawing -- just use the show and hide hilite routines
  1272. in this port -- then update to the screen for flicker free scrolling.
  1273.  
  1274. And the reason the Finder doesn't use the DragPreScroll and DragPostScroll
  1275. routines is because:
  1276.   1. They don't use offscreen drawing (probably to use minimal memory)
  1277.   2. The Drag Manager and Finder version 7.1.x were developed concurrently
  1278.   3. and Francis, the fabulous Finder Engineer, promised he was going to
  1279. use
  1280.      them but never got around to adding them before finishing the
  1281. Finder...
  1282.      everyone in unison now: "bad Francis..."
  1283.  
  1284. Thank You,
  1285. Dave Evans
  1286. not a Finder engineer
  1287.  
  1288. - --
  1289. Apple Computer, Inc. pays the bills but doesn't necessarily endorse
  1290. what I put in writing.  (especially after 1 am)
  1291.  
  1292. ---------------------------
  1293.  
  1294. End of C.S.M.P. Digest
  1295. **********************
  1296.  
  1297.  
  1298.  
  1299.